package com.zh.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zh.common.QueryPageParam;
import com.zh.common.Result;
import com.zh.entity.Goods;
import com.zh.entity.GoodsType;
import com.zh.service.GoodsService;
import com.zh.service.GoodsTypeService;
import com.zh.service.StorageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zh
 * @since 2025-04-06
 */
@RestController 
@RequestMapping("/goods")
@Slf4j
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("/save")
    public boolean save(@RequestBody Goods goods) {
        return goodsService.save(goods);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Goods goods) {
        return goodsService.updateById(goods);
    }

    @DeleteMapping("/delete")
    public boolean delete(@RequestParam Integer id) {
        return goodsService.removeById(id);
    }

    /**
     * 分页查询
     * @param queryPageParam
     * @return
     */
    @PostMapping("/listPage")
    public Result listPage(@RequestBody QueryPageParam queryPageParam) {
        return goodsService.listGoodsPage(queryPageParam);
    }

}
